package com.qikecn.api.listener;

import java.util.HashMap;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;


public class SessionAttributeListener implements HttpSessionAttributeListener {
	
	//private static final HashSet<HttpSession> sessionSet = new HashSet<HttpSession>();
	/*public static HashSet<HttpSession> getSessionset() {
		return sessionSet;
	}*/
	
	private static final HashMap<String, HttpSession> sessionMap = new HashMap<String, HttpSession>();

	@Override
	public void attributeAdded(HttpSessionBindingEvent arg0) {
		// TODO Auto-generated method stub
		/*arg0.getSession().setMaxInactiveInterval(Contents.SESSION_TIMEOUT);
		String name = arg0.getName();
		if(name != null){
			if(name.equals(SessionUtil.KEY_USERID)){
				Object value = arg0.getValue();
				if(value != null){
					sessionMap.put(value.toString(), arg0.getSession());
				}
			}
		}*/
	}

	@Override
	public void attributeRemoved(HttpSessionBindingEvent arg0) {
		// TODO Auto-generated method stub
		/*String name = arg0.getName();
		if(name != null){
			if(name.equals(SessionUtil.KEY_USERID)){
				Object value = arg0.getValue();
				if(value != null){
					sessionMap.remove(value.toString());
				}
			}
		}*/
	}

	@Override
	public void attributeReplaced(HttpSessionBindingEvent arg0) {
		// TODO Auto-generated method stub
		/*String name = arg0.getName();
		if(name != null){
			if(name.equals(SessionUtil.KEY_USERID)){
				Object value = arg0.getValue();
				if(value != null){
					sessionMap.put(value.toString(), arg0.getSession());
				}
			}
		}*/
	}

	public static HashMap<String, HttpSession> getSessionmap() {
		return sessionMap;
	}
	
}
